<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Photos.aspx.cs" Inherits="Photos" Title="My Photos" %>
<%@ Import Namespace="Friendster.Service" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <fs:FriendsterApplication runat="server" ID="fsApplication" ApplicationKey="0c868a9a9f2d332000cd09e1ed602ddc"
    ApplicationName="Creating .NET Client" Secret="7234cc4ad7689d0f8031b2023e252a3d" CallbackUrl="http://localhost:1653/StepByStep/" />
<%
    Response.Write("<div style=\"padding-left:20px\"><strong>My Photos</strong><br /><br />");
    if (Page.IsPostBack)
    {
        if (file.HasFile && file.FileContent.Length != 0)
        {
            HttpPostedFile postedFile = file.PostedFile;
            Photo photo = fsApplication.Service.Photos.UploadPhoto(postedFile.FileName, postedFile.InputStream, "image/jpeg", "StepByStep Application");
        }
    }
    Photo[] photos = (Photo[])fsApplication.Service.Photos.GetPhotosOfUser();
    if (photos.Length > 0)
    {
        Response.Write("<table width='95%'>");
        int index = 0;
        for(int i=0;i<photos.Length;i++)
        {
            Response.Write("<tr>");
            for (int j = 0; (j < 4)&&(index<photos.Length); j++)
            {
                Response.Write("<td width='25%' align='center'>");
                Response.Write("<a href=" + photos[index].LargeImageUrl + ">");
                Response.Write("<img border=0 src=" + photos[index].MediumImageUrl + " /></a><br />");
                Response.Write(photos[index++].Caption + "</td>");
            }
            Response.Write("</tr>");
        }
        Response.Write("</table>");
    }
    else
        Response.Write("<strong>You have no Photos</strong>");
%>
<br />
<div>
<strong>Upload New Photo:</strong><br />
<asp:FileUpload runat="server" ID="file" /><br />
<input type="submit" value="Upload" />
</div>

</asp:Content>

